package com.briup.estore.web.servlet;


import com.briup.estore.common.result.Result;
import com.briup.estore.common.utils.JsonUtils;
import com.briup.estore.service.CollectService;
import com.briup.estore.service.impl.CollectServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author briup-adam
 * @Date 2023/8/4 上午9:43
 * @Description  删除用户收藏 支持批量删除
 **/

@WebServlet("/collect/del")
public class CollectDelServlet extends BaseServlet {
    private CollectService collectService=new CollectServiceImpl();

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String data = readData(req);
        int[] ids = JsonUtils.toObject(data, int[].class);
        collectService.deleteCollect(ids);
        writeData(resp, Result.success());
    }
}
